// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.TransformManagement;

public sealed partial class Destination
{
	/// <summary>
	/// <para>The destination index for the transform. The mappings of the destination index are deduced based on the source<br/>fields when possible. If alternate mappings are required, use the create index API prior to starting the<br/>transform.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("index")]
	public Elastic.Clients.Elasticsearch.Serverless.IndexName? Index { get; set; }

	/// <summary>
	/// <para>The unique identifier for an ingest pipeline.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("pipeline")]
	public string? Pipeline { get; set; }
}

public sealed partial class DestinationDescriptor : SerializableDescriptor<DestinationDescriptor>
{
	internal DestinationDescriptor(Action<DestinationDescriptor> configure) => configure.Invoke(this);

	public DestinationDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Serverless.IndexName? IndexValue { get; set; }
	private string? PipelineValue { get; set; }

	/// <summary>
	/// <para>The destination index for the transform. The mappings of the destination index are deduced based on the source<br/>fields when possible. If alternate mappings are required, use the create index API prior to starting the<br/>transform.</para>
	/// </summary>
	public DestinationDescriptor Index(Elastic.Clients.Elasticsearch.Serverless.IndexName? index)
	{
		IndexValue = index;
		return Self;
	}

	/// <summary>
	/// <para>The unique identifier for an ingest pipeline.</para>
	/// </summary>
	public DestinationDescriptor Pipeline(string? pipeline)
	{
		PipelineValue = pipeline;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (IndexValue is not null)
		{
			writer.WritePropertyName("index");
			JsonSerializer.Serialize(writer, IndexValue, options);
		}

		if (!string.IsNullOrEmpty(PipelineValue))
		{
			writer.WritePropertyName("pipeline");
			writer.WriteStringValue(PipelineValue);
		}

		writer.WriteEndObject();
	}
}